let signInForm = null;

$(function() {
  signInForm = $('#signInForm');
  signInForm.submit(function(event) {
    event.preventDefault();
    let CaptchaAppId = '2054640852';

    let captcha = new TencentCaptcha($('#loginButton').get(0), CaptchaAppId, (res) => {
      if (res.ret === 0) {
        
        $.ajax({
          url: '/check007',
          data: JSON.stringify({
            ticket: res.ticket,
            randstr: res.randstr,
          }),
          contentType: 'application/json',
          method: 'POST',
          success: [function (data, textStatus, jqXHR) {
            // console.log(data);
            
    
          }],
          error: [function (jqXHR, textStatus, errorThrown) {
            console.log("check failure");
          }]
        });
        // window.location.assign("submit.html");
      }
    });
    captcha.show();

    // let value = {};
    // signInForm.find('input').each(function(index, e){
    //   value[$(e).attr('name')] = $(e).attr('type') === 'checkbox' ? $(e).prop('checked') : $(e).val();
    // });
    // console.log(value);
    // localStorage.setItem('mine', 'Tom');
    // window.location.assign("submit.html");
    // $.ajax({
    //   url: 'submit.html',
    //   contentType: 'application/json',
    //   method: 'GET',
    //   success: [function(data, textStatus, jqXHR) {
    //     console.log(data);
        
    //   }],
    //   error: [function(jqXHR, textStatus, errorThrown ) {

    //   }]
    // });
  });
});